extends ItemBt

var msgbox
var tooltips
var utils = globalData.infoDs["g_azurlaneUtils"]
var gSys = globalData.infoDs["g_azurlaneSys"]
func msgbox_init():
	tooltips = globalData.infoDs["g_azurlaneTooltips"]
	msgbox = tooltips.new_msgbox()
	gSys = globalData.infoDs["g_azurlaneSys"]
	connect("tree_exiting", msgbox, "queue_free")
	topUi.add_child(msgbox)

func enter():
	if is_instance_valid(item) and not utils.isMobile():
		if topUi.has_node("itemMsgBox"):
			var itemMsgBox = topUi.get_node("itemMsgBox")
			itemMsgBox.visible = false
			itemMsgBox.get_parent().remove_child(itemMsgBox)
			itemMsgBox.queue_free()
		msgbox_init()
		msgbox.bbcode_text = tooltips.getInfo(item)
		tooltips.calc_poistion_and_size(msgbox, self)
		msgbox.visible = true
	.enter()

func exit():
	if is_instance_valid(msgbox) and not utils.isMobile():
		msgbox.visible = false
	.exit()

func _on_item_pressed():
	var msg = sys.newMsg("itemInfoMsg")
	utils.changeScript(msg, gSys.itemInfoMsgScript)
	msg.init(item, tooltips.getInfo(item))

func setCha(cha):
	if cha.team == 1 and (cha.items.size() < cha.maxItem or utils.isExtraItem(item)):
		if item.masCha != null:
			item.masCha.delItem(item)
		if cha.addItem(item):
			masCha = cha    